#ifndef MAINBOX_H
#define MAINBOX_H

#include <QWidget>
#include <QDebug>
#include <QTextBrowser>
#include <QPushButton>
#include <QLineEdit>
#include <QPlainTextEdit>
#include <QDateTime>
#include <QThread>
#include <QTimer>
#include <QMessageBox>
#include <QCompleter>
#include <QStatusBar>
#include "qlua.h"
#include "qlinetools.h"
#include "qprinttools.h"
#include "qconfigtools.h"
#include "qloghelper.h"

QT_BEGIN_NAMESPACE
namespace Ui
{
    class MainBox;
}

QT_END_NAMESPACE

class MainBox : public QWidget
{
    Q_OBJECT

public:
    MainBox(QWidget *parent = nullptr);
    ~MainBox();

signals:
    void SendLine();
    void DisLine();
    void SendCmd(QString cmd);
    void SendWorking(bool b);
    void SendMessages(QStringList command);

private:
    Ui::MainBox* ui;
    QLua* L;
    QConfigTools* C;
    QLineTools* ltools;
    QThread* ltools_thread;
    QPrintTools* ptools;
    QThread* ptools_thread;
    QTimer* m_timer;
    QLogHelper* m_loghelper;
    QLabel* m_LineStatus;

    QCompleter* m_ProductCompleter = nullptr;
    QCompleter* m_WorkingCompleter = nullptr;
    bool flag = false;

private slots:
    void debug(QString s);
    void Logbrowser(QString text, int c);
    void SystemInfoBrowser(QString text, int c);
    void LineTimeOut();
    void LineStatus(bool b);
    void UpDataConfigJson();
    void ClearTextEdit(int num);

    void on_m_PrintData_clicked();

    void on_m_ReadScriptCommand_clicked();

    void on_m_LinePrint_clicked();

    void on_m_CloseLine_clicked();

    void on_m_SendCommand_clicked();

    void on_m_SetPrintIP_clicked();

    void on_m_ResetScript_clicked();

    void on_m_ScriptPrint_clicked();

    void on_m_LinePrint_2_clicked();

    void on_m_PrintData_2_clicked();

private:
    void PrintLog(QString s, int color = 0);
    void UI_Init(void);
    void Object_Init(void);
    void LineTool(void);
    bool IP_Port_Verify();
    void LineDevDisplay(bool b);
};

#endif // MAINBOX_H
